package com.zyf.ppx.utils

import android.content.Context

object DisplayUtils {
    /**
     * convert px to its equivalent dp
     *
     * 将px转换为与之相等的dp
     */
    fun px2dp(context: Context, pxValue:Float ):Int {
        var scale =  context.resources.displayMetrics.density
        return (pxValue / scale + 0.5f).toInt()
    }
    fun dp2px(context: Context, dipValue:Float ):Int {
        var scale =  context.resources.displayMetrics.density
        return (dipValue * scale + 0.5f).toInt()
    }
}